<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<link rel="stylesheet" type="text/css" href="../css/common.css?01_39" />
		<link rel="stylesheet" type="text/css" href="../css/templet.css?01_39" />
		<link rel="stylesheet" type="text/css" href="../fonts/font-awesome.min.css?01_39" />
		<link rel="stylesheet" type="text/css" href="../mui/css/mui.css?01_39" />
		<!--公共js-->
		<script type="text/javascript" src="../common/js/jquery.js?01_39"></script>

		<!--插件-->
		<script type="text/javascript" src="../common/js/vue.min.js?01_39"></script>
		<script type="text/javascript" src="../common/js/mui.min.js?01_39"></script>

		<script type="text/javascript" src="../common/js/fastclick.js?01_39"></script>
		<script type="text/javascript" src="../common/js/common.js?01_39"></script>
		<script type="text/javascript" src="../common/js/main.js?01_39"></script>
		<script type="text/javascript" src="../common/js/app.js?01_39"></script>
		<style>
			.hide {
				display: none;
			}
			
			.jurisdiction {
				position: fixed;
			}
		</style>
	</head>

	<body id="body">
		<header class="bg-red9 fff f-20 pad-t-10 pad-b-10 pad-r-10">
			<div class="pa back pad-l-10 back re" onclick="header_back()">
				<div class="order_back"></div>
				<a></a>
			</div>
			<div data-l="1217" class="center"></div>
		</header>
		<div id="app" class="wrap_body table_status pr" v-cloak style="background: url(../images/background_img.jpg) top center; background-size:100% 100% ;">
			<div v-if="clock_v">
				<div id="test" class="content pad-l-12 pad-r-12 pad-t-45">
					<!--大厅-->
					<div v-for="(v,k) in table" class="lobby">
						<div class="cf pad-t-12 pad-b-12 f-15 a15900">
							<div class="fl">{{v.table_cate_name}}</div>
							<div class="fr">{{v.num}}<span></span><span>/</span><span>{{v.list.length}}</span></div>
						</div>

						<div class="state cf">
							<div v-for="(v,k,i) in v.list" class="item fl mag-b-10" style="height: 137px; overflow: hidden;">
								<div @click="openTable(v)" v-if="!subscribe_list[v.id]" class="pad-l-5 pad-t-5 pad-r-5 a15900 f-16" :class="{'opacity_3':v.opacity==1}">
									<!--<div class="top center pad-t-10 pad-b-20 pr" :class="{'bg-fff':v.d,'shadow':v.d}">-->
									<div class="top center pad-t-10 pad-b-20 pr" :class="{'bg-fff':v.d&&!subscribe_list[v.id],'shadow':v.d,'bg-fef':subscribe_list[v.id]}">
										<div class="msg" v-if="v.d==4"></div>
										<p style="" class="ellipsis">{{v.table_name}}</p>
										<div v-if="v.time_p>=v.period-300&&v.period!=0" class="fiex mag-t-10" style="justify-content: center; width: 80%; position: absolute; left: 0; right: 0; bottom: 14px; margin: auto;height:15px;">
											<img src="../images/zhong.png" / style="width: 15px; height: 15px;">
											<div v-if="v.time_p<=v.period" class="f-10  red  ellipsis fiex1">{{b_lg['1402']}}</div>
											<div v-else class="f-10 fiex1 red ellipsis">{{b_lg['1403']}}</div>
										</div>
										<p class="foot_color" :style="{'background':v.color}"></p>
										<p v-if="v.time_p<v.period-300||v.period==0" class="pad-t-10">
											<span v-if="v.d==1" class="bg bg_01"></span>
											<span v-else-if="v.d==2" class="bg bg_02"></span>
											<span v-else-if="v.d==3" class="bg bg_03"></span>
											<!--<span v-else-if="v.d==4" class="bg bg_04"></span>-->
											<span v-else class="bg"></span>
										</p>
									</div>

									<div class="bottom cf pad-t-8 pad-b-5 f-13 fiex">
										<div><span v-if="v.reach_p==undefined">0</span><span v-else>{{v.reach_p}}</span><span>/</span><span>{{v.table_count}}</span></div>
										<div class="pr fiex1">
											<div class="fiex" style="justify-content: flex-end;">
												<div class="clock mag-r-3 pr"></div>
												<div class="ellipsis">{{v.time_p|ti}}</div>
											</div>
										</div>
									</div>
								</div>
								<div v-else class="pad-l-5 pad-t-5 pad-r-5 a15900 f-16" :class="{'opacity_3':v.opacity==1}" @click="subscribe_cli()">
									<div class="top center pad-t-10 pad-b-20 pr" :class="{'bg-fff':v.d&&!subscribe_list[v.id],'shadow':v.d,'bg-fef':subscribe_list[v.id]}">
										<div class="msg" v-if="v.time_p>=v.period+300"></div>
										<p style="" class="ellipsis">{{v.table_name}}</p>
										<div class="mag-t-10">{{b_lg[1404]}}</div>
									</div>
									<div class="bottom cf pad-t-8 pad-b-5 f-13">
										<div class="fl"><span v-if="v.reach_p==undefined">0</span><span v-else>{{v.reach_p}}</span><span>/</span><span>0</span></div>
										<div class="fr pr"><span class="clock mag-r-3 pr"></span><span style="max-width: 40px;" class="ellipsis">00:00</span></div>
									</div>
								</div>
							</div>

						</div>

					</div>
				</div>

				<!--桌台信息-->
				<transition name="fade">
					<div v-if="table_info" @click="closePage" id="table_info_mask" class="mask"></div>
				</transition>
				<transition name="slide-fade">
					<!--<div v-if="table_info" class="table_info" style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 99;">-->
					<div v-if="table_info" id="mask_2" class="info_wrap mask_1 table_info" style="position: fixed; bottom: 0; left: 0; width: 100%;  z-index: 99;">
						<div class="bg-red9 fff pad-l-12 f-20 f-b pad-t-10 pad-b-5 cf title">
							<div class="fl ellipsis t">{{order.table_name}}{{b_lg[1237]}}</div>
							<div class=" mag-t-3 pad-l-20 pad-r-12 fr" @click="closePage"><span class="close"></span></div>
						</div>

						<div id="table_msg" class="pad-l-12 pad-r-12 bg-fff c000">
							<div class="pad-t-20 pad-b-20">
								<div class="cf">
									<div class="col-sm-6">{{b_lg[1228]}}：<span class="blue">{{order.shop_table.addtime}}</span></div>
									<div class="oh pad-l-15">{{b_lg[1231]}}：<span class="blue">{{order.shop_table.pax}}</span></div>
								</div>
								<div class="mag-t-5 cf">
									<div class="col-sm-6">{{b_lg[1273]}}：<span class="blue">{{order.shop_table.count2}}</span></div>
									<div class="oh pad-l-15">{{b_lg[1232]}}：<span class="blue">{{order.shop_table.count3}}</span></div>
								</div>
								<div class="mag-t-5 cf">
									<div>{{b_lg[1230]}}：<span class="red9">{{order.shop_table.total}}</span></div>
								</div>
							</div>

							<div class="center cf f-15 pad-b-15">
								<div v-if="op_order==1" @click="click_order(order.id,order.table_name,1)" class="opt pad-t-20 pad-b-20 fl mag-t-10 active">
									<p class="opt_bg opt_01"></p>
									<p class="mag-t-10">{{b_lg[1233]}}</p>
								</div>
								<div v-if="op_order==2" @click="click_order(order.id,order.table_name,2)" class="opt pad-t-20 pad-b-20 fl mag-t-10 active">
									<p class="opt_bg opt_01"></p>
									<p class="mag-t-10">{{b_lg[1324]}}</p>
								</div>
								<div @click="click_print(order.id)" class="opt pad-t-20 pad-b-20 fl mag-t-10">
									<p class="opt_bg opt_02"></p>
									<p class="mag-t-10">{{b_lg[1234]}}</p>
								</div>
								<div @click="change_table(order.id,order.table_name,order.nth,order.table_cate_id)" class="opt pad-t-20 pad-b-20 fl mag-t-10">
									<p class="opt_bg opt_03"></p>
									<p class="mag-t-10">{{b_lg[1235]}}</p>
								</div>
								<div @click="add_dish()" class="opt pad-t-20 pad-b-20 fl mag-t-10">
									<p class="opt_bg opt_04"></p>
									<p class="mag-t-10">{{b_lg[1236]}}</p>
								</div>
							</div>
						</div>
					</div>
					<!--</div>-->
				</transition>
				<!--开桌-->
				<transition name="fade">
					<div v-if="table_open" id="table_open_mask" class="mask" @click="closePage()"></div>
				</transition>
				<transition name="slide-fade">
					<!--<div class="table_open" v-if="table_open" style="position: fixed; width: 100%; height: 100%; left: 0; top: 0;">-->
					<div v-if="table_open" id="mask_1" class="open_wrap mask_1 table_open" style="position: fixed; width: 100%;  left: 0; bottom: 0;max-height:560px;">

						<div class="bg-red9 fff pad-l-12 f-20 f-b pad-t-10 pad-b-10 cf title">
							<div class="fl ellipsis t">{{order.table_name}}{{b_lg[1237]}}</div>
							<div class=" pad-l-20 pad-r-12 fr" style="vertical-align: bottom; height: 27px; margin-top: 1px;" @click="closePage()">
								<span class="close"></span>
							</div>
						</div>

						<div class="info c000 bg-fff">
							<div v-if="sel_book" class="pad-l-12 pad-r-12  f-15 sel_menu">
								<p class="f-18 pad-t-15 pad-b-15">{{b_lg[1238]}}</p>
								<div id="sel-book-btn">
									<!--222-->
									<div class="center" style=" white-space: nowrap; overflow: auto;">
										<!--选择菜谱-->
										<div v-for="(v,k) in sel_cookbook" v-if="v.show==1" style="display: inline-block;" @click="select_cookbook(v,k)" :class="{active:k== sle_cookbook}" class="menu mag-b-5 pad-t-8 pad-b-8">{{v.cookbook_name}}</div>
									</div>
								</div>
								<div style="height: 10px;" class="pad-t-10">
									<div v-if="error_box" class="red center">{{error_msg}}</div>
								</div>
							</div>
							<div class="pad-l-12 pad-r-12 pad-t-15 pad-b-30 f-15 num_dine">
								<p class="f-18">{{b_lg[1231]}}</p>
								<div class="cf center mag-t-15 f-36 red9">
									{{peop_num}}
								</div>
							</div>
							<!--数字键盘-->
							<div class="keyboard center cf">
								<div class="number col-sm-9 f-18">
									<div v-for="(v,k) in list" @touchstart="click_num(v)" class="n col-sm-4 pad-t-16 pad-b-16 btn_c">{{v}}</div>
									<div class="n col-sm-4 pad-t-30 pad-b-30 btn_c"> </div>
									<div @touchstart="click_num(0)" class="n col-sm-4 pad-t-16 pad-b-16 btn_c">0</div>
									<div class="n col-sm-4 pad-t-30 pad-b-30 btn_c"> </div>
								</div>

								<div class="fun col-sm-3">
									<div @touchstart="del_num" class="n col-sm-12 pad-t-20 pad-b-15 delete btn_c"><span class="del"></span></div>
									<div class="col-sm-12 bg-red9 fff ok btn_c">
										<a @click="ok_btn" class="bk fff pad-t-80 pad-b-80">OK</a>
									</div>
								</div>
							</div>
						</div>
					</div>
					<!--</div>-->
				</transition>
				<!--接口未加载完成界面-->
				<div v-else>
					<div class="mask bg-000 pa loading">
						<div class="pad-l-40 pad-r-40 pad-t-200">
							<div class="bg-fff wrap pr center ">
								<img src="../images/default_graph/animation.gif" />
							</div>
						</div>
					</div>
				</div>
			</div>

			<script type="text/javascript">
				var app = null

				function back_table(type) {
					app.init();
				}

				function refresh() { //刷新方法
					app.init();
					app.load_fun1(); //关闭选择选择弹窗

				}

				function cli_back() {
					app.my_table_back()
				}

				function web_s() { //监听socket 用户开桌
					app.init();
				}

				function header_back() {
					app.header_back()
				}

				function fun1() {

					//如果是通过首页打开的修改订单页面,并且进行了下厨操作执执行以下
					var clo_order = getQueryString("close")
					if(clo_order == 'Order') {
						var ms = plus.webview.currentWebview().opener()
						plus.webview.close(ms.id, false)
					}
					setlange_obj(); //加载头部语言包
					if(isAPP) {
						down_load();
					}
					var table = JSON.parse(getItem("table"));
					var foods = JSON.parse(getItem("foods"));
					var jso_tab = JSON.parse(getItem("table"));
					var menu_all = {} //菜谱
					var food = {}; //所有菜品
					var spec = {}; //规格
					var garnish = {}; //配菜
					var taste = {}; //口味
					var jso_tab_id = {}; //桌号
					var h1_result = null
					app = new Vue({
						el: '#app',
						data: {
							verification_data: {}, //缓存数据
							verification_memory: "", //缓存需要验证的功能
							verification_el: null, //存储点击的桌子
							verification_state: "0", //验证是否通过
							verification_window: 0, //验证权限窗口
							verification_data: {
								account: "",
								password: "",
								rule_id: ""
							},
							conceal: false,
							table: null,
							foods: "",
							table_info: false, //已经开桌
							table_open: false, //开桌窗口是否打开
							get_home_list: null,
							open_table: null, //接口返回开桌的情况
							order: {}, //开桌
							peop_num: "1", //点餐人数
							shop_table_cookbook: "", //菜谱
							sle_cookbook: "1", //选择菜谱
							sel_msg: "1", //选择菜谱后提示语
							b_lg: global_lange, //语言包
							clock_v: false,
							error_msg: "", //时菜谱不可用提示语
							error_box: false, //菜谱不可用错误提示框是否显示
							sel_cookbook: {}, //可以选择的菜谱
							cookbook_name: {}, //菜谱的名字
							detail: {}, //菜谱详情
							table_deail: {}, //餐桌情况
							sel_book: false, //选择菜谱是否显示
							list: 9,
							num_bth: false, //是否填写人数
							sel_sub: false, //是否选择菜谱
							cookbook_id: "", //菜谱id用于页面跳转传递参数
							table_zone: "", //存储所选餐桌所属的分区用于页面跳转使用
							op_order: "1", //1:查看订单 2:确认订单
							change_table_type: "1", //是否换桌状态是否开启 1:未开启 2:开启
							change_table_memory: {
								table_id: "",
								table_name: "",
								table_nth: "",
								table_cate_id: ""
							}, //记录换桌id 餐桌名字  餐桌序号 餐桌分区
							peop_first: "1",
							subscribe_list: {} //预约列表

						},
						mounted: function() {
							this.foods = JSON.parse(getItem("foods"));
							this.table_deail = JSON.parse(getItem("table_deail"));
							this.verification_memory = JSON.parse(getItem("shop_table_cookbook")).rule_list;

						},
						filters: { //Vue过滤时间
							ti: function(value) {
								var dinner_time = formatDuring(value * 1000); //用餐时间
								if(!value) {
									return "00:00"

								} else if(dinner_time.d != 0) {

									return dinner_time.d + app.b_lg['1333'] + dinner_time.h + ":" + dinner_time.m

								} else {
									return dinner_time.h + ":" + dinner_time.m
								}

							}
						},
						methods: {
							header_back: function() { //判断页面顶部返回键是否需要关闭换桌状态
								if(app.change_table_type == 1) { //未开启
									back()
								} else {
									app.my_table_back()

								}
							},
							subscribe_fun: function(e, locking, zhanyong, kaizhuo) {

								//获取当前时间戳
								var zhan = (zhanyong) * 60
								var loc = (locking) * 60
								//								var tt = Date.parse(new Date()) / 1000;
								var tt = Date.parse(new Date(getItem("now_time") * 1000)) / 1000;
								//解析出超出预约时间的餐桌
								$.each(e, function(k, v) {
									if(kaizhuo[k]) { //过滤掉已经开桌的
										delete e[k]
									}
									if(v.time - loc >= tt || v.time + zhan > tt) { //过滤掉不在时间范围内的
										delete e[k]
									}
								});

								return e
							},
							subscribe_cli: function() { //预约开桌
								var btnArray = [app.b_lg['1049'], app.b_lg['1190']]
								mui.confirm(app.b_lg['1405'], app.b_lg['1320'], btnArray, function(e) {}, "div")
							},
							my_table_back: function() {
								if(app.change_table_type == 2) { //该判断用于换桌时点击返回时退出换桌状态
									$.each(app.table, function(k, v) {
										$.each(v.list, function(k_2, v_2) {
											if(v_2.d) {
												delete v_2.opacity
											}
										})
									})
									app.change_table_type = 1 //恢复打开面板状态
									app.init()
								} else {
									back()
								}
							},
							conceal_btn: function() {
								app.conceal = true
							},
							click_order: function(table_id, table_name, type) {
								// setTimeout(j(), 1000)

								$("#body").removeClass("open_fixed")

								j()

								function j() {
									if(type == 1) {
										jum("../set/confirmedOrder.html?table=" + table_id + "&type=1");
									} else if(type == 2) {
										jum("../set/changeOrder.html?table=" + table_id + "&leave=table");
									}

								}
								setTimeout(function() {
									app.table_info = false
								}, 1200)

							},
							click_print: function(id) { //打印桌单
								$("#body").removeClass("open_fixed")
								var btnArray = [app.b_lg['1049'], app.b_lg['1008']];
								mui.confirm(app.b_lg['1325'], app.b_lg['1320'], btnArray, function(e) {
									if(e.index == 1) {
										common_ajax("1", {
											shop_table_id: id,
											language: '0'
										}, "send_print_order_to_customer", function(h) {
											mui.toast(h.msg);
										});
									}
								}, "div")
							},
							change_table: function(table_id, table_name, table_nth, table_cate_id) { //换桌
								verify(87, function(e) {
									if(e == 1) {
										change_tab(table_id, table_name, table_nth, table_cate_id);
									} else {
										mui.alert(app.b_lg["1499"], app.b_lg["1320"], app.b_lg["1190"], function() {}, "div")
									}

								})
								//							change_tab(table_id1,table_name1,table_nth1,table_cate_id1);
								function change_tab(table_id, table_name, table_nth, table_cate_id) {
									$("#body").removeClass("open_fixed")
									app.change_table_memory = {
										table_id: table_id,
										table_name: table_name,
										table_nth: table_nth,
										table_cate_id: table_cate_id
									} //记录需要进行换桌的id

									var btnArray = [app.b_lg['1049'], app.b_lg['1190']]
									if(isAPP) {
										Android_back_order("change_table")
									}
									app.change_table_type = 2 //开启换桌状态
									app.table_info = false
									$.each(app.table, function(k, v) {
										$.each(v.list, function(k_2, v_2) {
											if(v_2.d) {
												v_2.opacity = 1
											}
										})
									})

								}

							},
							add_dish: function() { //加菜
								verify(86, function(e) {
									if(e == 1) {
										add_dis()
									} else {
										mui.alert(app.b_lg["1499"], app.b_lg["1320"], app.b_lg["1190"], function() {}, "div")
									}

								})

								function add_dis() {
									$("#body").removeClass("open_fixed")
									app.table_info = false
									setTimeout(j(), 1000)

									function j() {
										var a = app.order.shop_table
										jum("../set/order.html?table_id=" + app.order.id + "&old=1&back=tab_sta");
									}
								}

							},
							select_cookbook: function(k, v) { //当选择菜谱时判断当前时间是否可以使用菜谱 v:当前选择菜谱id k:当前菜谱详情
								var table = {}; //分区餐桌所属菜谱
								var table_zone = app.order.table_cate_id; //当前餐桌的分区
								app.table_zone = table_zone;
								this.sle_cookbook = v;
								$.each(app.shop_table_cookbook.shop_table_cate_list, function(k, v) {
									table[v.id] = v.cookbook_id;
								});
								setItem("book_zone", JSON.stringify(table)); //该缓存用于点餐界面使用
								//判断当前菜谱是否在本分区可以使用
								if(table[table_zone].indexOf(v) == -1) {
									app.error_msg = app.b_lg['1327'];
									app.error_box = true;
									app.sel_sub = false;
									return;
								}

								app.cookbook_id = v;

								function time1(s) { //计算方法
									var nn = new Date(getItem("now_time") * 1000);
									nn.setTime(s * 1000);
									return nn.format("hhmmss");

								}
								var cood = app.detail[v];
								console.log("cood", cood)
								//获取当前时间
								var timestamp = Date.parse(new Date(getItem("now_time") * 1000));
								//判断当天时候可以使用
								if(cood.week != "") {
									var nwerk = new Date(getItem("now_time") * 1000);
									var now_week = getweek(nwerk);
									if(cood.week.indexOf(now_week) == '-1') {
										app.error_msg = app.b_lg['1295'];
										app.error_box = true;
										app.sel_sub = false;
										return;
									} else {
										cook_time()
									}
								} else {
									cook_time()
								}

								function cook_time() { //对于菜谱的时间做判定
									if(cood.begin_time == 0 && cood.begin_time1 == 0 && cood.begin_time2 == 0) { //没有设置时间
										app.error_msg = "";
										app.error_box = false;
										app.sel_sub = true;
									} else {
										var time_obj = {}
										time_obj[1] = {
											'begin_time': cood.begin_time,
											'end_time': cood.end_time
										}
										time_obj[2] = {
											'begin_time': cood.begin_time1,
											'end_time': cood.end_time1
										}
										time_obj[3] = {
											'begin_time': cood.begin_time2,
											'end_time': cood.end_time2
										}
										$.each(time_obj, function(k, v) {
											if(v.begin_time != 0) {
												var str = timeQuantum(v.begin_time, v.end_time);
												if(str == 1) {
													return false
												}
											}
										});
									}

								}

								function timeQuantum(begin_time, end_time) { //辨别多个时间段
									if(begin_time > 0 && end_time > 0) { //判断是否设置了时间(判断今天的时间段是否可以使用)
										var now_time = time1(timestamp / 1000); //当前时间
										var begin_time = time1(begin_time);
										var end_time = time1(end_time);

										if(end_time > begin_time) {
											//									当天
											if(begin_time < now_time && end_time > now_time) {
												app.error_msg = "";
												app.error_box = false;
												app.sel_sub = true;
												return 1; //可以使用
											} else {
												app.error_msg = app.b_lg['1239'];
												app.error_box = true;
												app.sel_sub = false;
											}
										} else {
											//									隔天
											if(begin_time > now_time && end_time < now_time) {
												app.error_msg = "";
												app.error_box = false;
												app.sel_sub = true;
												return 1; //可以使用
											} else {
												app.error_msg = app.b_lg['1239'];
												app.error_box = true;
												app.sel_sub = false;
											}
										}
									}
								}
								var beg_time = cood.begin_time;
							},
							del_num: function() { //删除点餐键盘的数字
								app.peop_num = app.peop_num.substring(0, app.peop_num.length - 1);
								if(!app.peop_num) {
									app.peop_num = "0";
								}
								app.peop_first = 2
							},
							click_num: function(h) { //输入用餐人数
								var regex = /^[0]+/;
								if(app.peop_first != 1) {
									var el = event.currentTarget
									if(app.peop_num == 0 && h == 0) {
										return;
									}
									if(app.peop_num.length >= 2) {
										app.peop_num = "99"
										return
									}
									app.peop_num = String(app.peop_num + h);
									app.peop_num = app.peop_num.replace(regex, "");
								} else {
									if(h == 1) {
										app.peop_num = "11";
									} else {
										app.peop_num = String(h);
									}
								}
								//								222
								app.peop_first = 2

							},
							openTable: function(el) { //打开开桌面板
								app.verification_el = el;
								set_p.support = false
								if(app.change_table_type == 2 && !el.opacity) {
									var btnArray = [app.b_lg['1049'], app.b_lg['1190']]
									mui.confirm(app.b_lg['1328'] + ' ' + app.change_table_memory.table_name + ' ' + app.b_lg['1329'] + ' ' + el.table_name + '', app.b_lg['1320'], btnArray, function(e) {
										if(e.index == 1) {
											var a = app.change_table_memory
											common_ajax("1", {
												shop_table_id: el.id,
												shop_table_id_old: a.table_id
											}, "put_order_info_table", function(h) {
												if(h.status == 1) {
													app.change_table_fun(a.table_id, el.id)
													app.change_table_type = 1 //关闭换桌状态
												} else {
													mui.toast(h.msg)
												}

											})

										}
									}, "div")

								} else if(app.change_table_type == 1) {
									app.order = el;
									console.log("el", el);
									//判断当前点击的餐桌是否开桌
									if(el.d == "2") { //已经开桌
										setTimeout(function() {
											document.getElementById("mask_2").addEventListener('touchmove', function(e) {
												e.preventDefault()
											}, false)
											document.getElementById("table_info_mask").addEventListener('touchmove', function(e) {
												e.preventDefault()
											}, false)
										}, 500)

										function open_table1() {
											app.op_order = 1 //打开确认订单按钮
											common_ajax("1", {
												'shop_table_id': el.id
											}, "get_shop_table_info", function(h) { //获取桌面的详细信息
												app.order.shop_table = h.result;
												app.v_table_num = el
												app.table_info = true;
											})
										}
										open_table1();

									} else if(el.d == "4") {
										app.op_order = 2 //打开确认订单按钮
										common_ajax("1", {
											'shop_table_id': el.id
										}, "get_shop_table_info", function(h) { //获取桌面的详细信息
											app.order.shop_table = h.result;
											app.v_table_num = el
											app.table_info = true;
										})
									} else { //未开桌
										//判断菜谱的个数为多少个 如果为将选择菜谱按钮影藏
										verify(81, function(e) {
											if(e == 1) {
												open_table();
											} else {
												mui.alert(app.b_lg["1499"], app.b_lg["1320"], app.b_lg["1190"], function() {}, "div")
											}

										})

										function open_table() {
											app.sel_cookbook = JSON.parse(getItem("cookbook"));

											console.log("app.sel_cookbook", app.sel_cookbook);
											var cookbook_num = Object.keys(app.sel_cookbook).length,
											 	vartime  = getItem("now_time");
											//添加是否显示
											$.each(app.sel_cookbook, function(k, v) {
												var s = 1;
												if(v.available_btime1 != "0" && v.available_etime1 != "0" && s) { //如果有显示时段
													if(v.available_btime1 < vartime && v.available_etime1 > vartime) {
														s = 1;
													} else {
														s = 0;
													}
												}
												if(v.unavailable_btime1 != "0" && v.unavailable_etime1 != "0" && s) { //如果有隐藏时段
													if(v.unavailable_btime1 < vartime && v.unavailable_etime1 > vartime) {
														s = 0;
													} else {
														s = 1;
													}
												}
												v.show = s;
											})
											//添加是否显示end
											$.each(app.sel_cookbook, function(v, k) {
												app.select_cookbook(k, v)
												return false;
											})
											if(cookbook_num == 0) {
												mui.alert(app.b_lg['1330']);
												return;
											}
											if(cookbook_num == 1) {
												app.sel_book = false //隐藏选择菜谱按钮
											} else {
												app.sel_book = true //开启选择菜谱按钮
											}
											//以下代码为是否显示菜谱的代码，考虑到如果只有一个就不显示那么无法知道选择的是那个故以下逻辑暂不执行
//											//判断显示菜谱的个数如果数量为1那么隐藏选择菜谱按钮
//											var show_len = 0; //显示菜谱的个数
//											$.each(app.sel_cookbook,function(k,v){
//												if(v.show==1){
//													show_len++;
//												}
//											})
//											if(show_len<2){
//												app.sel_book = false //隐藏选择菜谱按钮
//											}
											var table_cate_id = el.table_cate_id; //餐桌所属分区
											app.table_open = true;
										}

									}
								}

							},
							closePage: function() { //关闭开桌面板
								app.verification_window = 0 //关闭权限窗口
								app.table_info = false
								app.table_open = false
								app.error_box = false
								app.peop_first = 1
								app.sle_cookbook = 1
								app.error_msg = "" //清空菜谱错误提示语
								app.peop_num = "1" //清空数字键盘的人数

							},
							load_fun1: function() { //用于跳页后关闭窗口
								app.error_msg = ""
								app.sel_sub = ""
								app.sle_cookbook = 1
								app.peop_num = 1
								app.table_open = false //关闭点餐界面
								app.table_info = false //关闭餐桌详情页面
							},
							//刷新方法
							init: function() {
								var shop_ver = getItem("shop_ver");
								var table_statue_ver = getItem("order_ver");
								common_ajax("1", {}, "get_table_working", function(h1) { //获取餐厅用餐情况
									if(h1.status != 1) { //判断接口是否调用成功
										mui.toast(h1.msg);
										return;
									}
									console.log("h1.result.subscribe_list", h1.result)
									app.shop_table_cookbook = JSON.parse(getItem("shop_table_cookbook"))
									//缓存分区可以使用的菜谱情况
									//查找桌号id
									jso_tab_id = JSON.parse(getItem("jso_tab_id"))
									//菜谱详细信息
									$.each(app.shop_table_cookbook.cookbook_list, function(k, v) {
										app.detail[v.id] = v;
									});
									//清空已经开的桌子(重新统计数量)
									$.each(jso_tab, function(k, v) {
										v.num = 0
										$.each(v.list, function(k_1, v_1) {
											v_1.d = 0
											v_1.time_p = 0; //用户用餐时间
											v_1.reach_p = 0; //用户用餐人数
											v_1.color = "" //加入颜色
										});
									})
									$.each(h1.result.list, function(k, v) { //有哪些桌子开桌
										if(k == 0) {
											return
										}
										var ke = jso_tab_id[k]; //已经开桌的桌子
										if(!ke) {
											return true
										}
										var vl = jso_tab[ke.o].list[ke.i];
										jso_tab[ke.o].num++; //餐桌数量
										if(v.has_goods != 0) {
											vl.d = "4"
										} else {
											vl.d = "2"
										}
										vl.color = v.color //加入颜色
										//d判断是否正在用餐 0:未开桌 2:代表正在用餐 4:呼叫服务员 5:预约
										vl.time_p = v.time; //用户用餐时间
										vl.reach_p = v.pax; //用户用餐人数
									});
									app.table = jso_tab;
									var res = h1.result //处理接口返回结果
									app.subscribe_list = app.subscribe_fun(res.subscribe_list, res.subscribe_info_msg.locking, res.zhanyong, h1.result.list) //解析出已经超时的预约餐桌
									var table = {}
									$.each(app.shop_table_cookbook.shop_table_cate_list, function(k, v) {
										table[v.id] = v.cookbook_id
									})
									setItem("book_zone", JSON.stringify(table)) //该缓存用于点餐界面使用
									if(shop_ver != table_statue_ver) {
										$.each(app.shop_table_cookbook.cookbook_list, function(k, v) { //菜谱名称
											app.cookbook_name[v.id] = v.cookbook_name;
										});

										setItem("cookbook_name", JSON.stringify(app.cookbook_name))
										setItem("table_statue_ver", shop_ver)
									} else {
										app.cookbook_name = JSON.parse(getItem("cookbook_name"))
									}
									app.clock_v = true;
									//缓存上架商品(用于order估清菜品使用)
									common_ajax("1", {}, "get_shop_goods_status_list", function(h) {
										setItem("goods_status_list", JSON.stringify(h.result.list));
										setItem("change_price", JSON.stringify(h.result));
									})
								});
							},
							change_table_fun: function(now_table_id, old_table_id) { //换桌方法
								memory_a = now_table_id
								memory_b = old_table_id
								var now_key = ""
								var old_key = ""
								//							var table_deail = JSON.parse(getItem("table_deail"))
								var now_classify = app.table_deail[now_table_id].table_cate_id //当前餐桌分区
								var old_classify = app.table_deail[old_table_id].table_cate_id //将要换桌餐桌的分区

								$.each(app.table, function(k, v) {
									$.each(v.list, function(k_1, v_1) {
										if(v_1.id == now_table_id) {
											now_key = v_1.nth
										}
										if(v_1.id == old_table_id) {
											old_key = v_1.nth
										}
										if(now_key && old_key) {
											return false
										}
									})
									if(now_key && old_key) {
										return false
									}
								})

								var b = app.table[now_classify].list[now_key] //a.table_cate_id:餐桌所在分区 a.table_nth:桌号
								var c = app.table[old_classify].list[old_key] //el.table_cate_id:餐桌所在分区   el.nth:桌号
								c.d = b.d
								c.opacity = b.opacity
								c.reach_p = b.reach_p
								c.shop_table = b.shop_table
								c.time_p = b.time_p
								app.table[old_classify].list[old_key] = c
								delete b.d
								delete b.opacity
								b.reach_p = 0
								b.shop_table = {}
								b.time_p = 0
								app.table[now_classify].list[now_key] = b
								$.each(app.table, function(k, v) {
									$.each(v.list, function(k_2, v_2) {
										if(v_2.d) {
											delete v_2.opacity
										}
									})
								})
								var e = app.table
								app.table = {}
								app.table = e

							},
							order_food: function(table_type, type) { //呼叫服务员 以及用户自己下单 以及开桌
								app.init()
							},
							test: function() {
								console.log("app.table", app.table)
								var data = []
								var obj = {
									table_id: 300
								}
								data.push(obj)
								app.order_food(data, "put_order_confirm")
							},
							ok_btn: function() { //确认下单按钮
								$("#body").removeClass("open_fixed")
								if(!app.sel_book) {
									if(!app.sel_book) {
										$.each(app.sel_cookbook, function(k, v) {
											app.cookbook_id = v.id
											app.sel_sub = true
											var table_zone = app.order.table_cate_id //当前餐桌的分区
											app.table_zone = table_zone
										})
									}
								}
								if(app.sel_sub && app.peop_num != 0) { //当人数以及菜谱均已选择完成可以点击ok键
									var num_bth = app.peop_num
									app.sle_cookbook = 1 //清空所选菜谱的状态
									app.error_msg = "" //清空错误提示语
									app.sel_sub = ""
									jum("../set/order.html?cookbook_id=" + app.cookbook_id + "&num_bth=" + num_bth + "&table_zone=" + app.table_zone + "&table_name=" + app.order.table_name + "&table_id=" + app.order.id + "&old=0&back=tab_sta");

								} else {
									if(!app.sel_sub) {
										if(app.error_msg == "") {
											mui.toast(app.b_lg['1331']);
											return;
										}
										mui.toast(app.error_msg);
									} else {
										if(app.peop_num == 0) {
											mui.toast(app.b_lg['1332']);
										}
									}
								}
							},
							load_fun: function() {
								common_ajax("1", {}, "get_table_working", function(h1) {
									if(h1.status != 1) { //判断接口是否调用成功
										mui.toast(h1.msg);
										return;
									}
									$.each(h1.result.list, function(k, v) {
										if(k == 0) {
											return
										}
										var ke = jso_tab_id[k]; //已经开桌的桌子
										var vl = jso_tab[ke.o].list[ke.i];
										jso_tab[ke.o].num++; //餐桌数量
										if(v.has_goods != 0) {
											vl.d = "4"
										} else {
											vl.d = "2"
										}
										//d判断是否正在用餐 0:未开桌 2:代表正在用餐 3:呼叫服务员 
										vl.time_p = v.time; //用户用餐时间
										vl.reach_p = v.pax; //用户用餐人数
										//											vl.time = jso_tab[ke.o].list[ke.i];
									});
								}) //获取餐厅用餐情况
							}
						}
					})
					app.init();
					//定时检查餐桌是否已经过期 1分钟间隔
					setInterval(function() {
						app.init()
					}, 60000)
					if(isAPP) {
						var ws = plus.webview.currentWebview();
						setItem("tableStatus.html", ws.id)
					}
					// 监听“返回”按钮事件
					if(isAPP) {
						//重写mui但返回按钮事件
						mui.back = function() {

						}
					}

					function Android_back_order(page) {
						plus.key.removeEventListener("backbutton", close_food);
						if(page == "change_table") {
							plus.key.addEventListener("backbutton", close_food, false);
						}
					}

					function close_food() {
						app.my_table_back()
						And_back('remove')
					}
				}
			</script>
	</body>

</html>